<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">


      <el-form-item label="报告医生" prop="ptdtBgdoctor">
        <el-input
          v-model="queryParams.ptdtBgdoctor"
          placeholder="请输入报告医生"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>



      <el-form-item label="${comment}" prop="jwtechnician3">
        <el-input
          v-model="queryParams.jwtechnician3"
          placeholder="请输入${comment}"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="ptdtFcbs">
        <el-input
          v-model="queryParams.ptdtFcbs"
          placeholder="请输入${comment}"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['report:ptdetail:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['report:ptdetail:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['report:ptdetail:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['report:ptdetail:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="ptdetailList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="检查设备" align="center" prop="ptdtCheckmachine" />
      <el-table-column label="报告医生" align="center" prop="ptdtBgdoctor" />
      <el-table-column label="审核医生" align="center" prop="ptdtShdoctor" />
      <el-table-column label="报告日期" align="center" prop="ptdtReportdate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.ptdtReportdate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="临床所见" align="center" prop="ptdtLcmessage" />

      <el-table-column label="临床诊断" align="center" prop="ptdtLcdiagnous" />

      <!-- <el-table-column label="检查所见" align="center" prop="ptdtChecksj" />

      <el-table-column label="检查意见" align="center" prop="ptdtCheckyj" /> -->

      <el-table-column label="检查部位" align="center" prop="ptdtCheckbw" />
      <el-table-column label="检查项目名称" align="center" prop="ptdtCheckname" />
      <!-- <el-table-column label="审核所见" align="center" prop="ptdtShsj" /> -->
      <el-table-column label="审核意见" align="center" prop="ptdtShyj" />
      <el-table-column label="患者优先级" align="center" prop="ptdtPatientpriority" />
      <el-table-column label="报告病史" align="center" prop="ptdtBgready" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['report:ptdetail:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['report:ptdetail:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改检查信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="${comment}" prop="ptdtPatientid">
          <el-input v-model="form.ptdtPatientid" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtCheckcode">
          <el-input v-model="form.ptdtCheckcode" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtInhoscode">
          <el-input v-model="form.ptdtInhoscode" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtBedcode">
          <el-input v-model="form.ptdtBedcode" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtBarea">
          <el-input v-model="form.ptdtBarea" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtSqhos">
          <el-input v-model="form.ptdtSqhos" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtSqdept">
          <el-input v-model="form.ptdtSqdept" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtSqdoctor">
          <el-input v-model="form.ptdtSqdoctor" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtCheckid">
          <el-input v-model="form.ptdtCheckid" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtCheckmachine">
          <el-input v-model="form.ptdtCheckmachine" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="报告医生" prop="ptdtBgdoctor">
          <el-input v-model="form.ptdtBgdoctor" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtShdoctor">
          <el-input v-model="form.ptdtShdoctor" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtDjdate">
          <el-date-picker clearable size="small"
            v-model="form.ptdtDjdate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择${comment}">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtDjdoctor">
          <el-input v-model="form.ptdtDjdoctor" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtCheckdate">
          <el-date-picker clearable size="small"
            v-model="form.ptdtCheckdate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择${comment}">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="报告日期" prop="ptdtReportdate">
          <el-date-picker clearable size="small"
            v-model="form.ptdtReportdate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择${comment}">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="检查所见" prop="ptdtChecksj">
          <el-input v-model="form.ptdtChecksj" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="检查意见" prop="ptdtCheckyj">
          <el-input v-model="form.ptdtCheckyj" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="检查项目名称" prop="ptdtCheckname">
          <el-input v-model="form.ptdtCheckname" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="processtechnician">
          <el-input v-model="form.processtechnician" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="ptdtOperdatetime">
          <el-date-picker clearable size="small"
            v-model="form.ptdtOperdatetime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择${comment}">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="报告病史" prop="ptdtBgready">
          <el-input v-model="form.ptdtBgready" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listPtdetail, getPtdetail, delPtdetail, addPtdetail, updatePtdetail } from "@/api/report/ptdetail";

export default {
  name: "Ptdetail",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 检查信息表格数据
      ptdetailList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ptdtPatientid: null,
        ptdtCheckcode: null,
        ptdtInhoscode: null,
        ptdtBedcode: null,
        ptdtBarea: null,
        ptdtSqhos: null,
        ptdtSqdept: null,
        ptdtSqdoctor: null,
        ptdtCheckid: null,
        ptdtCheckmachine: null,
        ptdtBgdoctor: null,
        ptdtShdoctor: null,
        ptdtDjdate: null,
        ptdtDjdoctor: null,
        ptdtCheckdate: null,
        ptdtReportdate: null,
        ptdtLcmessage: null,
        ptdtLcmessagetxt: null,
        ptdtLcdiagnous: null,
        ptdtLcdiagnoustxt: null,
        ptdtChecksj: null,
        ptdtChecksjtxt: null,
        ptdtCheckyj: null,
        ptdtCheckyjtxt: null,
        ptdtSaveposition: null,
        ptdtNoreport: null,
        ptdtHadreport: null,
        ptdtAuditinged: null,
        ptdtCheckbw: null,
        ptdtCheckmedicine: null,
        ptdtMedmethod: null,
        ptdtDosage: null,
        ptdtAdopt: null,
        ptdtCheckname: null,
        ptdtWorkload: null,
        ptdtCheckprice: null,
        ptdtXxj: null,
        ptdtWordreport: null,
        ptdtWordtitle: null,
        ptdtSfphoto: null,
        ptdtAge: null,
        ptdtWeight: null,
        ptdtWzdoctor: null,
        ptdtPhotomes: null,
        ptdtHsbs: null,
        ptdtShdate: null,
        ptdtShsj: null,
        ptdtShyj: null,
        ptdtShsjtxt: null,
        ptdtShyjtxt: null,
        injecttechnician: null,
        aquisitiontechnician: null,
        processtechnician: null,
        jwtechnician: null,
        jwcheckname: null,
        ydcltechnician: null,
        ydcldoctor: null,
        cjtechnician2: null,
        jwcheckname2: null,
        jwcheckname3: null,
        jwtechnician2: null,
        jwtechnician3: null,
        ptdtFcbs: null,
        ptdtPicnote: null,
        jwcheckname4: null,
        jwcheckname5: null,
        jwtechnician4: null,
        jwtechnician5: null,
        jwmodality: null,
        jwmodality2: null,
        jwmodality3: null,
        jwmodality4: null,
        jwmodality5: null,
        savedisctechnician: null,
        savediscdoctor: null,
        savedatetime: null,
        yddatetime: null,
        ptdtBgdoctor2: null,
        ptdtShdoctor2: null,
        injectlzztechnician: null,
        ctaquisitiontechnician: null,
        injectlzztechnichcian: null,
        ptdtReportdate1: null,
        ptdtReportdate2: null,
        ptdtReportdatetime: null,
        ptdtHeight: null,
        ptdtStatus: null,
        ptdtOpstatustime: null,
        ptdtPatientpriority: null,
        ptdtAutoassign: null,
        ptdtBgproreadytxt: null,
        ptdtShproreadytxt: null,
        ptdtBgproready: null,
        ptdtShproready: null,
        ptdtBookptdeid: null,
        printcount: null,
        ptdtOperdatetime: null,
        ptdtHide: null,
        accessionNumber: null,
        studyid: null,
        ptdtBloodglucose: null,
        ptdtSicktype: null,
        ptdtSurveyflag: null,
        ptdtXxjtxt: null,
        ptdtDosageunit: null,
        ptdtDiseasetype: null,
        ptdtBgreadytxt: null,
        ptdtShreadytxt: null,
        ptdtBgready: null,
        ptdtShready: null,
        ptdtAdvice: null,
        ptdtPositive: null,
        ptdtShdate2: null,
        ptdtBranch: null,
        pdfFilename: null,
        ptdtCheckintime: null,
        ptdtSpecial: null,
        ptdtCheckorder: null,
        ptdtDevposi: null,
        pathologictype: null,
        ptdtUid: null,
        ptdtPtuid: null,
        studyinsta: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询检查信息列表 */
    getList() {
      this.loading = true;
      listPtdetail(this.queryParams).then(response => {
        this.ptdetailList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        ptdeid: null,
        ptdtPatientid: null,
        ptdtCheckcode: null,
        ptdtInhoscode: null,
        ptdtBedcode: null,
        ptdtBarea: null,
        ptdtSqhos: null,
        ptdtSqdept: null,
        ptdtSqdoctor: null,
        ptdtCheckid: null,
        ptdtCheckmachine: null,
        ptdtBgdoctor: null,
        ptdtShdoctor: null,
        ptdtDjdate: null,
        ptdtDjdoctor: null,
        ptdtCheckdate: null,
        ptdtReportdate: null,
        ptdtLcmessage: null,
        ptdtLcmessagetxt: null,
        ptdtLcdiagnous: null,
        ptdtLcdiagnoustxt: null,
        ptdtChecksj: null,
        ptdtChecksjtxt: null,
        ptdtCheckyj: null,
        ptdtCheckyjtxt: null,
        ptdtSaveposition: null,
        ptdtNoreport: null,
        ptdtHadreport: null,
        ptdtAuditinged: null,
        ptdtCheckbw: null,
        ptdtCheckmedicine: null,
        ptdtMedmethod: null,
        ptdtDosage: null,
        ptdtAdopt: null,
        ptdtCheckname: null,
        ptdtWorkload: null,
        ptdtCheckprice: null,
        ptdtXxj: null,
        ptdtWordreport: null,
        ptdtWordtitle: null,
        ptdtSfphoto: null,
        ptdtAge: null,
        ptdtWeight: null,
        ptdtWzdoctor: null,
        ptdtPhotomes: null,
        ptdtHsbs: null,
        ptdtShdate: null,
        ptdtShsj: null,
        ptdtShyj: null,
        ptdtShsjtxt: null,
        ptdtShyjtxt: null,
        injecttechnician: null,
        aquisitiontechnician: null,
        processtechnician: null,
        jwtechnician: null,
        jwcheckname: null,
        ydcltechnician: null,
        ydcldoctor: null,
        cjtechnician2: null,
        jwcheckname2: null,
        jwcheckname3: null,
        jwtechnician2: null,
        jwtechnician3: null,
        ptdtFcbs: null,
        ptdtPicnote: null,
        jwcheckname4: null,
        jwcheckname5: null,
        jwtechnician4: null,
        jwtechnician5: null,
        jwmodality: null,
        jwmodality2: null,
        jwmodality3: null,
        jwmodality4: null,
        jwmodality5: null,
        savedisctechnician: null,
        savediscdoctor: null,
        savedatetime: null,
        yddatetime: null,
        ptdtBgdoctor2: null,
        ptdtShdoctor2: null,
        injectlzztechnician: null,
        ctaquisitiontechnician: null,
        injectlzztechnichcian: null,
        ptdtReportdate1: null,
        ptdtReportdate2: null,
        ptdtReportdatetime: null,
        ptdtHeight: null,
        ptdtStatus: "0",
        ptdtOpstatustime: null,
        ptdtPatientpriority: null,
        ptdtAutoassign: null,
        ptdtBgproreadytxt: null,
        ptdtShproreadytxt: null,
        ptdtBgproready: null,
        ptdtShproready: null,
        ptdtBookptdeid: null,
        printcount: null,
        ptdtOperdatetime: null,
        ptdtHide: null,
        accessionNumber: null,
        studyid: null,
        ptdtBloodglucose: null,
        ptdtSicktype: null,
        ptdtSurveyflag: null,
        ptdtXxjtxt: null,
        ptdtDosageunit: null,
        ptdtDiseasetype: null,
        ptdtBgreadytxt: null,
        ptdtShreadytxt: null,
        ptdtBgready: null,
        ptdtShready: null,
        ptdtAdvice: null,
        ptdtPositive: null,
        ptdtShdate2: null,
        ptdtBranch: null,
        pdfFilename: null,
        ptdtCheckintime: null,
        ptdtSpecial: null,
        ptdtCheckorder: null,
        ptdtDevposi: null,
        pathologictype: null,
        ptdtUid: null,
        ptdtPtuid: null,
        studyinsta: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.ptdeid)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加检查信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const ptdeid = row.ptdeid || this.ids
      getPtdetail(ptdeid).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改检查信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.ptdeid != null) {
            updatePtdetail(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPtdetail(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ptdeids = row.ptdeid || this.ids;
      this.$modal.confirm('是否确认删除检查信息编号为"' + ptdeids + '"的数据项？').then(function() {
        return delPtdetail(ptdeids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('report/ptdetail/export', {
        ...this.queryParams
      }, `ptdetail_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
